package cn01;

//数组查找对应位置的索引，采用方法完成案例

import java.util.Scanner;

@SuppressWarnings("all")

public class test10 {
    public static void main(String[] args) {
        int[] arr = {11, 22, 33, 44, 55, 66};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的数据");
        int number = sc.nextInt();
        int index = getindex(arr, number);
        System.out.println(index);

    }

    public static int getindex(int[] arr, int number) {
        int index = -1;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == number) {
                index = i;
                break;
            }

        }
        return index;
    }
}